package com.yun.platform.es.config;


import lombok.Data;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;

/*&*
* 这个类不需要也可以
 */
@Data
//@Configuration
//@ConfigurationProperties(prefix = "elasticsearch")
public class ElasticsearchConfig {
    private String host;

    private Integer port;

    /**
     * 注册es高级客户端
     * @return RestHighLevelClient
     */
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, "http"));
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(builder);
        return restHighLevelClient;
    }

}
